package stream;


import java.util.ArrayList;
import java.util.Collections;

public class StreamTest {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"猪八戒","唐僧","悟空","撒僧");
        System.out.println("for循环======");
        for (String name : list) {
            System.out.println(name);
        }
        System.out.println("流式操作=======");
        //stream可以理解为生产线上流式操作，x是每个元素
        list.stream().forEach(x->{
            System.out.println("x="+x);
        });
        System.out.println("流式简写==============");
        list.stream().forEach(System.out::println);
    }
}
